#include<bits/stdc++.h>
using namespace std;
int The_Alliance;
int dep[200010],fa[200010],n,a[200010],mx,id,tmp;
vector<int>e[200010];
void dfs(int x,int f){
	if(dep[x]!=-1)dep[x]=dep[f]+1;
	fa[x]=f;
	for(int i=0;i<e[x].size();i++)if(e[x][i]!=f)dfs(e[x][i],x);
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	freopen("forest.in","r",stdin);
	freopen("forest.out","w",stdout);
	cin>>The_Alliance>>n,dep[0]=-1;
	for(int i=2;i<=n;i++){
		cin>>a[i];
		e[i].push_back((id+mx)^a[i]);
		e[(id+mx)^a[i]].push_back(i);
		for(int j=1;j<=i;j++)dep[j]=0;
		dfs(1,0),mx=0,id=0;
		for(int j=1;j<=i;j++)if(dep[j]>mx)mx=dep[j],id=j;
		dfs(id,0),tmp=id,mx=0,id=0;
		for(int j=1;j<=i;j++)if(dep[j]>mx)mx=dep[j],id=j;
		while(id!=0)dep[id]=-1,id=fa[id];
		dfs(tmp,0),id=mx,mx=0;
		for(int j=1;j<=i;j++)if(dep[j]>mx)mx=dep[j];
		cout<<id+mx<<"\n";
	}
	return 0;
}
